package com.gmail.blackdog1987.carcare.network.response.handler;

import com.gmail.blackdog1987.carcare.network.ResponseCustomError;
import com.gmail.blackdog1987.carcare.network.response.IResponse;

/**
 * 
 * @author 董国超
 *
 */
public interface IResponseHandler {
	/** JSON解析失败 */
	public static final int CODE_JSON_PARSE_ERROR = 99990;
	/** 网络连接失败 */
	public static final int CODE_CONNECTION_ERROR = 99991;
	/** JSON解析错误 */
	public static final ResponseCustomError JSON_PARSE_ERROR = new ResponseCustomError("{\"msg\":\"json parse error.\"}}");
	/** 网络连接错误 */
	public static final ResponseCustomError CONNECTION_ERROR = new ResponseCustomError("{\"msg\":\"connection error.\"}}");

	/**
	 * 解析返回结果（Json格式）
	 * 
	 * @param response 解析对象 JSONObject或JSONArray
	 * @return true 解析成功 false 解析有错
	 */
	public boolean parseJson(Object response);

	/**
	 * 获取返回结果对象
	 * 
	 * @return 结果对象
	 */
	public IResponse getResponse();
}
